package com.poh.service.impl;

import com.poh.mapper.QuestionBankMapper;
import com.poh.pojo.Homework;
import com.poh.pojo.QuestionBank;
import com.poh.service.QuestionBankService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.List;

@Service
public class QuestionBankServiceImpl implements QuestionBankService {
    @Autowired
    QuestionBankMapper questionBankMapper;
    @Override
    public int addQuestionBank(QuestionBank questionBank) {
        LocalDate localDate = LocalDate.now();
        LocalTime localTime = LocalTime.now();
        questionBank.setQuestionBankTime(localDate.format(DateTimeFormatter.ISO_DATE) + " " + localTime);
        return questionBankMapper.addQuestionBank(questionBank);
    }

    @Override
    public int updateQuestionBank(QuestionBank questionBank) {
        return questionBankMapper.updateQuestionBank(questionBank);
    }

    @Override
    public int deleteQuestionBank(String questionBankId) {
        return questionBankMapper.deleteQuestionBank(questionBankId);
    }

    @Override
    public List<QuestionBank> queryQuestionBankByCourseId(int courseId) {
        return questionBankMapper.queryQuestionBankByCourseId(courseId);
    }

    @Override
    public QuestionBank queryQuestionBankById(String questionBankId) {
        return questionBankMapper.queryQuestionBankById(questionBankId);
    }
}
